package com.dlwx.parttimetalent.ui;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.dlwx.parttimetalent.R;
import com.dlwx.parttimetalent.base.BaseActivity;
import com.dlwx.parttimetalent.bean.LabelBean;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class CancelOrderActivity extends BaseActivity {

    @BindView(R.id.title_left_one_btn)
    ImageView titleLeftOneBtn;
    @BindView(R.id.tv_middle_title)
    TextView tvMiddleTitle;
    @BindView(R.id.flowlayout)
    TagFlowLayout flowlayout;
    @BindView(R.id.tv_content)
    EditText tvContent;
    @BindView(R.id.tv_confirm)
    TextView tvConfirm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cancel_order);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        titleLeftOneBtn.setVisibility(View.VISIBLE);
        tvMiddleTitle.setVisibility(View.VISIBLE);
        tvMiddleTitle.setText("拒绝理由");

        ArrayList<LabelBean> mDatas = new ArrayList<LabelBean>();
        for(int i=0;i<20;i++){
            LabelBean bean=new LabelBean();
            bean.setId(i);
            bean.setLabelName("理由"+i);
            mDatas.add(bean);
        }
//        flowlayout.setMaxSelectCount(1);
        TagAdapter<LabelBean> tagAdapter=new TagAdapter<LabelBean>(mDatas) {
            @Override
            public View getView(FlowLayout parent, int position, LabelBean labelBean) {
                String tip = labelBean.getLabelName();
                TextView textView = (TextView) LayoutInflater.from(CancelOrderActivity.this)
                        .inflate(R.layout.tv_label_red_select, flowlayout, false);
                textView.setText(tip);
                textView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
                return textView;
            }
        };
        flowlayout.setAdapter(tagAdapter);
    }

    @OnClick({R.id.title_left_one_btn, R.id.tv_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_left_one_btn:
                this.finish();
                break;
            case R.id.tv_confirm:
                break;
        }
    }
}
